package util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class DBUtils {
	private static Connection c;
	
	static {
		try {
			Properties pro = new Properties();
			pro.load(new FileInputStream("./jdbc.properties"));
			String driver = pro.getProperty("jdbc.driver");
			String url = pro.getProperty("jdbc.url");
			String user = pro.getProperty("jdbc.user");
			String password = pro.getProperty("jdbc.password");
			
			Class.forName(driver);
			c = DriverManager.getConnection(url,user,password);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static Connection getConnection() {
		return c;
	}
}
